home *** CD-ROM | disk | FTP | other *** search
- Path: spiff.cc.iastate.edu!graphix
- From: graphix@iastate.edu (Kent A Vander Velden)
- Newsgroups: comp.lang.c++
- Subject: Re: Derivation and calling virtual functions
- Date: 28 Mar 96 23:30:07 GMT
- Organization: Iowa State University, Ames, Iowa
- Message-ID: <graphix.828055807@spiff.cc.iastate.edu>
- References: <graphix.828032689@spiff.cc.iastate.edu>
- NNTP-Posting-Host: spiff.cc.iastate.edu
-
- This is a rewrite of my original post with corrections...
-
- Say we have the following:
-
- class Base {
- public:
- virtual void func() { // some stuff }
- virtual void write() { func(); }
- };
-
- class Derived : public Base {
- public:
- void func() { // some stuff }
- void write() { Base::write(); }
- };
-
- Derived inst;
-
- Now, when I call inst.write(), Base::write() is called which in
- turn calls Base::func(). Is there a way to instead have Base::write()
- call Derived::func() if Base::write() is called from any function
- defined in the Derived class or specificly Derived::write()? I hoped
- the virtual keyword would help in this case.
-
- Thanks.
-
- >--
- >Kent Vander Velden
- >graphix@iastate.edu
-
- --
- Kent Vander Velden
- graphix@iastate.edu
-
-